# Maintainer: Balló György <ballogyor+arch at gmail dot com>

pkgname=gtk-sharp-3
_pkgname=gtk-sharp
pkgver=2.99.3
pkgrel=5
pkgdesc='C# bindings for GTK+ 3'
arch=('loong64' 'x86_64')
url='https://www.mono-project.com/docs/gui/gtksharp/'
license=('LGPL')
depends=('mono' 'gtk3')
source=("https://download.gnome.org/sources/$_pkgname/${pkgver%.*}/$_pkgname-$pkgver.tar.xz"
        'fix-build.patch')
sha256sums=('6440f571416267ae0cb5698071d087b31e3084693fa2c829b1db37ca7ea2c3a2'
            '730fc67fae27451085a6b7cbd7a838561718bf8358b1ef8a77af01e341812f09')

prepare() {
  cd $_pkgname-$pkgver
  patch -Np1 -i ../fix-build.patch
  sed -i 's/gmcs/mcs/' configure{,.ac}
  sed -e '/MONO_PROFILE_ENTER_LEAVE/d' -i gtk/gui-thread-check/profiler/gui-thread-check.c # Fix build with newer mono
}

build() {
  cd $_pkgname-$pkgver
  ./configure --prefix=/usr
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd $_pkgname-$pkgver
  make DESTDIR="$pkgdir" install
}
